﻿using BW.IBll;
using BW.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoerlController : ControllerBase, IRoerlbLL
    {
         public RoerlController(IRoerlbLL bll,ILogger<ControllerBase> logger)
        {
            Bll = bll;
            Logger = logger;
        }

        public IRoerlbLL Bll { get; }
        public ILogger<ControllerBase> Logger { get; }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t">数据信息</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost]
        public Task<int> AddAnync(Roerl roerl)
        {
            try///异常处理
            {
                Logger.LogInformation($"添加一条数据");
                return Bll.AddAnync(roerl);
            }
            catch (Exception)
            {

                throw;
            }
           
        }

        /// <summary>
        /// 查询显示
        /// </summary>
        /// <param name="name">姓名</param>
        /// <param name="statesTypeId">职业id</param>
        /// <returns>通过姓名，职业查询数据获取一条数据</returns>
        /// 

        [HttpGet]
        public dynamic ShowRoerl(string? name, int statesTypeId)
        {
            try///异常处理
            {
                return Bll.ShowRoerl (name, statesTypeId);

            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
